package io.renren.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 判断是否是手机号
 * @author wfj
 * @date 2021/6/15 0015 14:59
 */
public class MobilePhoneUtils {
    private static final Pattern MOBILE_PATTERN = Pattern.compile("^[1][3,4,5,6,7,8,9][0-9]{9}$");
    public static boolean isMobilePhone(String mobiles){
        // 国内手机号
        if(mobiles.startsWith("1") && mobiles.length() == 11) {
            Matcher m = MOBILE_PATTERN.matcher(mobiles);
            return m.matches();
        }else if(mobiles.startsWith("852") && (mobiles.length() == 11 || mobiles.length()== 12)){
            //香港手机号
            return true;
        }else if(mobiles.startsWith("853") && mobiles.length() == 11){
            //澳门手机号
            return true;
        }
        return false;
    }
}
